home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 2 / CU Amiga Magazine's Super CD-ROM 02 (1996)(EMAP Images)(GB)[!][issue 1996-04].iso / magazine / amiga_e / jrh-rkrm-partone / preferences / prefnotify.e < prev    next >
Text File  |  1995-03-26  |  2KB  |  57 lines

  1. -> prefnotify.e - Notified if serial prefs change
  2. OPT PREPROCESS
  3.  
  4. MODULE 'dos/dos',
  5.        'dos/notify'
  6.  
  7. ENUM ERR_NONE, ERR_KICK, ERR_NOTIFY, ERR_SIGNAL
  8.  
  9. RAISE ERR_NOTIFY IF StartNotify()<>DOSTRUE,
  10.       ERR_SIGNAL IF AllocSignal()=255
  11.  
  12. #define PREFSFILENAME 'ENV:sys/serial.prefs'
  13.  
  14. PROC main() HANDLE
  15.   DEF done=FALSE, notifyrequest=NIL:PTR TO notifyrequest,
  16.       signum=255, signals
  17.   -> We need at least V37 for notification
  18.   IF KickVersion(37)=FALSE THEN Raise(ERR_KICK)
  19.   -> Allocate a NotifyRequest structure
  20.   NEW notifyrequest
  21.   -> And allocate signalsbit
  22.   signum:=AllocSignal(-1)
  23.   -> Initialise notification request
  24.   notifyrequest.name:=PREFSFILENAME
  25.   notifyrequest.flags:=NRF_SEND_SIGNAL
  26.   -> Signal this task...
  27.   notifyrequest.task:=FindTask(NIL)
  28.  
  29.   -> ... with this signals bit
  30.   notifyrequest.signalnum:=signum
  31.  
  32.   StartNotify(notifyrequest)
  33.   WriteF('Select Serial Prefs SAVE or USE to notify this program\n')
  34.   WriteF('CTRL-C to exit\n\n')
  35.   -> Loop until Ctrl-C to exit
  36.   REPEAT
  37.     signals:=Wait(Shl(1, signum) OR SIGBREAKF_CTRL_C)
  38.     IF signals AND Shl(1, signum)
  39.       WriteF('Notification signal received.\n')
  40.     ENDIF
  41.     IF signals AND SIGBREAKF_CTRL_C
  42.       EndNotify(notifyrequest)
  43.       done:=TRUE
  44.     ENDIF
  45.   UNTIL done
  46. EXCEPT DO
  47.   IF signum<>255 THEN FreeSignal(signum)
  48.   IF notifyrequest THEN END notifyrequest -> E-Note: not really necessary...
  49.   SELECT exception
  50.   CASE ERR_KICK;   WriteF('Requires at least V37\n')
  51.   CASE ERR_NOTIFY; WriteF('Can''t start notification\n')
  52.   CASE ERR_SIGNAL; WriteF('No signals available\n')
  53.   CASE "MEM";      WriteF('Not enough memory for NotifyRequest.\n')
  54.   ENDSELECT
  55. ENDPROC
  56.  
  57. verstag: CHAR 0, '$VER: prefnot 37.1 (09.07.91)', 0